package com.briup.smartcity_group1.exception;

import com.briup.smartcity_group1.utils.result.ResultCode;

/**业务异常
 * @author congee(congee02 @ 163.com)
 * @date 1/3/2023 1:20 PM
 */
public class ServiceException extends RuntimeException {

    private int status;

    /**
     * Constructs a new runtime exception with the specified detail message.
     * The cause is not initialized, and may subsequently be initialized by a
     * call to {@link #initCause}.
     *
     * @param message the detail message. The detail message is saved for
     *                later retrieval by the {@link #getMessage()} method.
     * @param status 状态码
     */
    public ServiceException(String message, int status) {
        super(message);
        this.status = status;
    }

    /**从没居中中提取消息和状态码 {@link #status}
     * @param codeEnum 状态码枚举
     */
    public ServiceException(ResultCode codeEnum) {
        super(codeEnum.getMsg());
        this.status = codeEnum.getCode();
    }

    public int getStatus() {
        return status;
    }
}
